var R = require('ramda');
var _ = require('lodash');

const M = require('ramda-fantasy').Maybe;
const Just = M.Just;
const Nothing = M.Nothing;

const safeDiv = R.curry((n, d) => d === 0 ? Nothing() : Just(n / d));
const lookup = R.curry((k, obj) => k in obj ? Just(obj[k]) : Nothing());

const sdk = R.curry((g) => {
  if (_.isEmpty(g)) {
    return Nothing()
  } else {
    return Just(g)
  }
});

// console.dir(safeDiv(10)(0));
// console.dir(lookup('foo', { foo: 'bar' }).getOrElse('baz'));
// console.dir(lookup('foo', { abc: 'bar' }).getOrElse('bar'));

let name = sdk(global.jssdk).getOrElse();
console.dir(name);
